home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE02 / XTOOLS / XTOOL.ZIP / DBFILTER.INT < prev    next >
Encoding:
Text File  |  1995-05-28  |  1.8 KB  |  59 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {       xTool - Component Collection                    }
  4. {                                                       }
  5. {       Copyright (c) 1995 Stefan B÷ther                }
  6. {                                                       }
  7. {*******************************************************}
  8. unit DbFilter;
  9.   { encapsulation of the BDE filter-function as a component }
  10.  
  11. interface
  12.  
  13. uses
  14.   WinTypes, WinProcs, SysUtils, Classes, Graphics, Dialogs,
  15.   Forms, Db, DbiTypes, DbiProcs;
  16.  
  17. type
  18.   TFilterEvent = function (Sender:TObject; Dataset:TDataSet): Boolean of object;
  19.  
  20.   TFilterDatalink = class;
  21.   TDbFilter       = class(TComponent)
  22.   private
  23.     FDatalink   : TFilterDatalink;
  24.     FOnFilter   : TFilterEvent;
  25.     FHandle     : hDBIFilter;
  26.     FPriority   : Word;
  27.     FRecSize    : Word;
  28.     FRecBuffer  : Pointer;
  29.     procedure   ActiveChanged;
  30.     function    GetDatasource:TDatasource;
  31.     procedure   SetDatasource(Value: TDatasource);
  32.     procedure   SetPriority(Value: Word);
  33.   protected
  34.     function    DoFilter(pRecBuf:Pointer): Boolean;
  35.   public
  36.     constructor Create(aOwner:TComponent); override;
  37.     destructor  Destroy; override;
  38.     property    Handle: hDBIFilter read FHandle;
  39.   published
  40.     property    Datasource: TDatasource read GetDatasource write SetDatasource;
  41.     property    Priority: Word read FPriority write SetPriority;
  42.     property    OnFilter: TFilterEvent read FOnFilter write FOnFilter;
  43.   end;
  44.  
  45.  { TFilterDataLink }
  46.  
  47.   TFilterDataLink = class(TDataLink)
  48.   private
  49.     FFilter : TDBFilter;
  50.   protected
  51.     procedure ActiveChanged; override;
  52.   public
  53.     constructor Create(AFilter: TDbFilter);
  54.     destructor Destroy; override;
  55.   end;
  56.  
  57.   procedure Register;
  58.  
  59.